package com.share.ai.langchain4j.utils;

import dev.langchain4j.data.document.DocumentParser;
import dev.langchain4j.data.document.parser.TextDocumentParser;

import java.util.Map;

public class FileParserUtil {

    private static Map<String, DocumentParser> documentParsers = Map.of(
            ".txt", new TextDocumentParser(),
            ".log", new TextDocumentParser(), //日志文件
//                ".pdf", new ApachePdfBoxDocumentParser(),
//                ".doc", new ApachePoiDocumentParser(),
//                ".docx", new ApachePoiDocumentParser(),
            ".md", new TextDocumentParser(),
            ".java", new TextDocumentParser(),
            ".py", new TextDocumentParser(),
            ".js", new TextDocumentParser(),
            ".html", new TextDocumentParser(),
            ".htm", new TextDocumentParser(),
            ".xml", new TextDocumentParser(),
            ".json", new TextDocumentParser()
    );

    public static DocumentParser getDocumentParser(String fileType) {
        return documentParsers.get(fileType);
    }
}
